04. For-In Loops
For-In Loops
Question:
Start Quiz:
Solution:
INSTRUCTOR NOTE:
Clarification
Use forEach
or for
to iterate over arrays like:
countries = ['Argentina', 'China', 'England'];
Use
for-in
to loop over objects like countries = {'country1':'Argentina', 'country2':'China','country3':'England'};
being careful to wrap the content of the
for-in
in a conditional statement that tests if the key is part of the object: myObj = {'country1':'Germany', 'country2':'Argentina'}; for (key in myObj){ if (myObj.hasOwnProperty(key)) { console.log(myObj[key]); } }</pre>
For more information, please refer to the loop section of the Udacity Front End Style Guide.:last
The
:last
jQuery selector returns the final element in a list that matches whatever precedes it.
So forwork-entry:last
, if there are 3work-entry
elements, it will only return the 3rd one.
If you're interested, you can read more about jQuery's:last
selector here.
For this quiz you'll work with theindex.html
andjs/resumeBuilder.js
files from the résumé project's Github repository you downloaded earlier in this lesson. Editjs/resumeBuilder.js
in your text editor, and view the results by openingindex.html
in the browser of your choice. Note that the HTML needed is stored injs/helper.js
variables.
Follow your instructors!
@cwpittman
+jameswilliams